import 'package:flutter/material.dart';
import 'package:flutter_app/values/MyColors.dart';
import 'package:flutter_app/widget/custom_app_bar.dart';
import 'package:flutter_screenutil/src/size_extension.dart';
import 'package:get/get.dart';

import '../../../r.dart';
import 'collect_logic.dart';

/**
 * @Description: 任务采集
 * @Author: 下雨了
 * @CreateDate: 2022年5月31日 13:59:55
 * @Version: 1.0
 */
///
class CollectPage extends StatefulWidget {
  final String title;

  const CollectPage({Key? key, required this.title}) : super(key: key);

  @override
  _CollectPageState createState() => _CollectPageState();
}

class _CollectPageState extends State<CollectPage> {
  final logic = Get.put(CollectLogic());
  final state = Get.find<CollectLogic>().state;


  @override
  Widget build(BuildContext context) {
    return GetBuilder<CollectLogic>(builder: (logic) {
      return Scaffold(
        backgroundColor: MyColors.FFF1F1F1,
        body: Stack(
          children: [
            Image.asset(R.assetsImgBg12),
            Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                MyAppBar(context, title: widget.title),
                Container(
                  height: 46.r,
                  padding: EdgeInsets.only(left: 4.r),
                  child: TabBar(
                    tabs: [for (final tab in state.tabs) Tab(text: tab,)],
                    // // 指示器
                    indicatorColor: Colors.white,
                    indicator: BoxDecoration(
                        borderRadius: BorderRadius.circular(2),
                        color: Colors.white),
                    indicatorPadding: EdgeInsets.only(left: 20.r, right: 20.r, top: 40.r, bottom: 4.r),
                    // 字体颜色
                    labelColor: Colors.white,
                    labelStyle: TextStyle(fontSize: 18.sp, fontWeight: FontWeight.w500),
                    labelPadding: EdgeInsets.only(left: 13.r, right: 13.r),
                    // 没有选中字体颜色
                    unselectedLabelColor: Colors.white,
                    unselectedLabelStyle: TextStyle(fontSize: 14.sp),
                    // 是否滚动
                    isScrollable: true,
                    // 控制器
                    controller: logic.controller,
                    physics: BouncingScrollPhysics(),
                  ),
                ),
                Expanded(
                    child: TabBarView(children: logic.widgets, controller: logic.controller,)
                ),
              ],
            ),
          ],
        ),
      );
    });
  }

  @override
  void dispose() {
    Get.delete<CollectLogic>();
    super.dispose();
  }
}